package com.wc.alorithm_blue_bridge._思维.狮子座的试炼;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/5/24 19:26
 * @description
 * https://www.lanqiao.cn/problems/20320/learning/?contest_id=255
 */
public class Main {
    /**
     * 思路：
     * 保证两个里面有一个1, 三个里面有两个1即可
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N], backUp = new int[N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();

        for (int i = 1;  i <= n; i++) backUp[i] = a[i] = sc.nextInt();
        for (int i = 1, j = n; i < j; i++, j--) {
            int tmp = backUp[i];
            backUp[i] = backUp[j];
            backUp[j] = tmp;
        }
        int res = Math.min(get(a), get(backUp));
        out.println(res);
        out.flush();
    }

    static int get(int[] a) {
        int res = 0;
        for (int i = 2; i <= n; i++) {
            if (i == 2 && a[i - 1] == 0) {
                a[i] = 1;
                res ++;
            }
            if (i >= 3) {
                if (a[i] == 0 && a[i - 1] + a[i - 2] < 2) {
                    a[i] = 1;
                    res++;
                }
            }
        }
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

